<template>
  <div class="addBtn flex-center"  >
    <i class="el-icon-plus" @click="goAdd"></i>
    <el-dialog
        title="新增apikey"
        :visible.sync="dialogVisible"
        width="500px">
      <el-form ref="form" :model="form" label-width="110px" :rules="rules">
        <el-form-item label="客户系统名称" prop="serviceName">
          <el-input v-model="form.serviceName"></el-input>
        </el-form-item>
        <el-form-item label="申请备注">
          <el-input type="textarea" v-model="form.applyRemark"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "addApiKeyBtn",
  data(){
    return {
      dialogVisible:false,
      form:{
        "applyRemark": "",
        "serviceName": ""
      },
      rules:{
        serviceName:[ { required: true, message: '请输入客户系统名称', trigger: 'blur' },]
      }
    }
  },
  methods:{
    goAdd(){
      this.dialogVisible = true
    },
    submit(){
      this.$refs.form.validate(v=>{
        if(v){
          this.$api.addApikey(this.form).then(res=>{
            this.dialogVisible = false
            this.$emit('after-op')
            this.$notify({
              title: '成功',
              message: '新增成功',
              type: 'success'
            });
          })
        }else{
          return false
        }
      })

    },
  },
}
</script>

<style scoped lang="less">
.addBtn{
  width: 180px;
  height: 180px;
  cursor: pointer;
  background-color: #F3F5F8;
i{
  font-size: 80px;
  color: #DADEE6;
}
}
</style>